package com.sitanyun.merchant.guide.adapter;

import android.content.Context;
import android.graphics.Color;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sitanyun.merchant.guide.R;
import com.sitanyun.merchant.guide.bean.ScenUserBean;

/**
 * Created by jzl
 * on 2021/12/25.
 * 用户VR弹窗列表
 */
public class ScenUsersAdapter extends BaseQuickAdapter<ScenUserBean.DataBean.ListBean, BaseViewHolder> {
   private String cids;
    public ScenUsersAdapter(Context context,String cid) {
        super(R.layout.item_scenuser);
        this.mContext = context;
        this.cids=cid;
    }

    @Override
    protected void convert(BaseViewHolder helper, ScenUserBean.DataBean.ListBean item) {
       ImageView cimg = helper.getView(R.id.cimg);
        ImageView stars = helper.getView(R.id.stars);
        ImageView starss = helper.getView(R.id.starss);
        ImageView starsss = helper.getView(R.id.starsss);
        Glide.with(mContext).load(item.getHeadUrl()).error(R.mipmap.cimg).into(cimg);
            ImageView zx=  helper.getView(R.id.userlist_xz);
            //选中
        if (cids!=null){
            if (item.getCId().equals(cids)){
                    Glide.with(mContext).load(R.mipmap.xzsuerlist).into(zx);
                }else {
                    Glide.with(mContext).load(R.mipmap.wxz_userlist).into(zx);
                }

        }else {
             Glide.with(mContext).load(R.mipmap.wxz_userlist).into(zx);
        }
          //名称
      // TextView  cname=  helper.getView(R.id.cname);
        if (item.getCName()==null){
            helper.setText(R.id.cname,"访客");
        }else {
            helper.setText(R.id.cname,item.getCName());
        }
        // helper.setText(R.id.cname,item.getCName());

        TextView lastbehavior=  helper.getView(R.id.lastBehavior);
        TextView times=  helper.getView(R.id.times);
         if (item.getOnline()==0){
             lastbehavior.setText("已离线");
         String lasttime=   item.getLastBehaviorTime();
             times.setText(lasttime.substring(10,16)+"前离线");
         }else {
             int intTime=item.getDuring();
             int h=intTime/3600;
             int m=(intTime%3600)/60;
             int s=(intTime%3600)%60;
             if (h==0){
                 times.setText("在线"+m+"分"+s+"秒");
             }else {
                 times.setText("在线"+h+"时"+m+"分");
             }
             if (item.getLastBehavior().equals("MESSAGE")){
                 lastbehavior.setText("留言待回复");

             }else if (item.getLastBehavior().equals("CALL")){
                 lastbehavior.setText("要求回电");
             }else if (item.getLastBehavior().equals("BROWSE_END")){
                 lastbehavior.setText("退出场景");
             } else if (item.getLastBehavior().equals("MEETING")){
                 lastbehavior.setText("同屏互动中");
                 lastbehavior.setTextColor(Color.parseColor("#FD6206"));
             }else if (item.getLastBehavior().equals("BROWSE")){
                 lastbehavior.setText("正在逛");
             }else {
                 lastbehavior.setText("在线");
             }

         }



          switch (item.getStars()){
              case 0:
                  Glide.with(mContext).load(R.mipmap.xwei).into(stars);
                  Glide.with(mContext).load(R.mipmap.xwei).into(starss);
                  Glide.with(mContext).load(R.mipmap.xwei).into(starsss);
                  break;
              case 1:
                  Glide.with(mContext).load(R.mipmap.xxuan).into(stars);
                  Glide.with(mContext).load(R.mipmap.xwei).into(starss);
                  Glide.with(mContext).load(R.mipmap.xwei).into(starsss);
                  break;
              case 2:
                  Glide.with(mContext).load(R.mipmap.xxuan).into(stars);
                  Glide.with(mContext).load(R.mipmap.xxuan).into(starss);
                  Glide.with(mContext).load(R.mipmap.xwei).into(starsss);
                  break;
              case 3:
                  Glide.with(mContext).load(R.mipmap.xxuan).into(stars);
                  Glide.with(mContext).load(R.mipmap.xxuan).into(starss);
                  Glide.with(mContext).load(R.mipmap.xxuan).into(starsss);
                  break;
          }



    }
}
